package ru.testtask.util;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

public class ConfigFactoryBean implements FactoryBean, InitializingBean {

    private String elemNames;

    private String attrNames;

    public void setElemNames(String elemNames) {
        this.elemNames = elemNames;
    }

    public void setAttrNames(String attrNames) {
        this.attrNames = attrNames;
    }

    @Override
    public Object getObject() throws Exception {
        return Config.getInstance();
    }

    @Override
    public Class<?> getObjectType() {
        return Config.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        Config.createInstance(elemNames, attrNames);
    }
}
